package com.zzl.bonds.ticket.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.zzl.bonds.ticket.dto.ApUserShowInfo;
import com.zzl.bonds.ticket.dto.KeyValue;
import com.zzl.bonds.ticket.dto.feign.ApprovalSubmitDto;
import com.zzl.bonds.ticket.dto.feign.NoticeApprovalResult;
import com.zzl.bonds.ticket.dto.finance.*;
import com.zzl.bonds.ticket.dto.ticketopen.CheckSubmit;
import com.zzl.bonds.ticket.entity.BusinessContractEntity;
import com.zzl.bonds.ticket.entity.TicketFinanceEntity;
import com.zzl.bonds.ticket.entity.TicketProcessEntity;
import com.zzl.general.common.exception.SysException;
import com.zzl.general.common.serurity.entity.User;
import com.zzl.general.common.utils.PageUtils;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * 融资申请单
 *
 * @author wztsl
 * @date 2022-02-24 13:53:42
 */
public interface TicketFinanceService extends IService<TicketFinanceEntity> {

    /**
     * 分页查询
     *
     * @param params 查询参数
     * @return 分页数据
     */
    PageUtils queryPage(Map<String, Object> params, User user) throws SysException;

    /**
     * 新增
     *
     * @param ticketFinanceAddDto 新增实体
     * @param user                当前登录用户
     * @throws SysException 业务异常
     */
    String saveTicketFinance(TicketFinanceAddDto ticketFinanceAddDto, User user) throws SysException;

    /**
     * 获取融资列表统计数据
     *
     * @param user 登录用户
     * @return 融资列表统计数据
     * @throws SysException 业务异常
     */
    TicketFinanceDataDto financeData(User user) throws SysException;

    /**
     * 根据主键查询融资详情
     *
     * @param id   主键
     * @param user 用户
     * @return 融资详情
     * @throws SysException 异常
     */
    TicketFinanceDto getFinanceDetailById(String id, User user) throws SysException;

    /**
     * 获取签署状态
     *
     * @param businessContractEntities 签署协议
     */
    void getContractSigner(List<BusinessContractEntity> businessContractEntities);

    /**
     * 凭证查询
     *
     * @param id   凭证id
     * @param user 用户
     * @return 我的凭证信息
     */
    MyTicketDetailDto getTicketInfoById(String id, User user) throws SysException;

    /**
     * 融资复核列表
     *
     * @param params 筛选条件
     * @param user   用户
     * @return 融资复核列表
     */
    PageUtils queryReviewFinancePage(Map<String, Object> params, User user, HttpSession session) throws SysException;

    /**
     * 融资复核详情
     *
     * @param id   融资id
     * @param user yoghurt
     * @return 融资详情
     * @throws SysException 异常
     */
    TicketFinanceReviewDto reviewInfo(String id, User user) throws SysException;

    /**
     * 融资复核提交
     *
     * @param checkSubmit 提交参数
     * @param user        用户
     */
    void financeTicketCheckSubmit(ApprovalSubmitDto checkSubmit, User user) throws SysException;

    /**
     * 融资签署列表
     *
     * @param params 筛选条件
     * @param user   用户
     * @return 融资签署列表
     */
    PageUtils querySignFinancePage(Map<String, Object> params, User user, HttpSession session);

    /**
     * 融资签署提交
     *
     * @param user 用户
     */
    void financeTicketSignSubmit(String id, User user) throws SysException;

    /**
     * 融资撤销
     *
     * @param id   融单申请id
     * @param user 用户
     */
    void financeTicketCancel(String id, User user) throws SysException;

    TicketFinanceEntity getByRetentionId(String id);

    TicketFinanceEntity getByParentId(String id);

    TicketFinanceEntity getByTicketRetentionId(String id);

    TicketFinanceEntity getByTicketId(String id);

    /**
     * 融资，平台审核提交
     *
     * @param checkSubmit 审核结果
     * @param user        登录用户
     */
    void financeTicketApproveSubmit(CheckSubmit checkSubmit, User user) throws SysException;

    void executeWaitingPayment(Integer days);

    /**
     * 融资审核列表
     *
     * @param params  筛选条件
     * @param user    登录用户
     * @param session session内容
     * @return 融资审核列表
     */
    PageUtils queryApproveFinancePage(Map<String, Object> params, User user, HttpSession session) throws SysException;

    /**
     * 融单审核详情
     *
     * @param id   融资申请id
     * @param user 用户
     * @return 融单审核详情
     */
    TicketFinanceDto getFinanceApproveDetail(String id, User user) throws SysException;

    /**
     * 融资协议列表
     *
     * @param params 筛选条件
     * @return 协议列表
     */
    List<ContractTemplateDto> getFinanceContractList(Map<String, Object> params);

    /**
     * 根据融资凭证号融单详情
     *
     * @param ticketNo 凭证编号
     * @return 融单详情
     */
    TicketFinanceOrderDto getFinanceByTicketNo(String ticketNo);

    /**
     * 融单管理详情
     *
     * @param id   融单id
     * @param user 用户
     * @return 融单管理详情
     */
    TicketFinanceDetailDto financeDetail(String id, User user) throws SysException;

    /**
     * 修改融资申请信息
     *
     * @param financeUpdateDto 修改内容
     * @param user             用户
     */
    void updateTicketFinanceById(TicketFinanceUpdateDto financeUpdateDto, User user) throws SysException;

    /**
     * 业务状态
     *
     * @param id 融单id
     * @return 业务状态
     */
    List<KeyValue> financeStatus(String id);

    /**
     * 根据不同的业务类型，创建电子合同
     *
     * @param id         业务id
     * @param ticketType 业务码
     * @throws SysException 业务异常
     */
    void setBusinessProtocol(String id, Integer ticketType) throws SysException;

    /**
     * 融单的流程进度
     *
     * @param id 融单id
     * @return 流程进度集合
     */
    List<ApUserShowInfo> getFinanceProcessProgress(String id) throws SysException;

    /**
     * 融资审批结束，流程的回调函数
     *
     * @param noticeApprovalResult 审批内容
     * @param ticketProcessEntity  流程
     * @param user                 用户
     */
    void ticketWithdrawCallback(NoticeApprovalResult noticeApprovalResult, TicketProcessEntity ticketProcessEntity, User user) throws SysException;
}

